<!doctype html public "-//W3C//DTD HTML 4.0 Frameset//EN""http://www.w3.org/TR/REC-html40/frameset.dtd">
<html>
<head>
<title>
ka-Map Overview
</title>
<link rel ="stylesheet" type="text/css" href="stylesheet.css" title="Style">
<script>
function asd() {
	
		parent.document.title="kaXmlOverlay.js Overview";
	
}
</script>
</head>
<body bgcolor="white" onload="asd();">

<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> 	<font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top">
<em>
<b>ka-Map</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<center>
	
	   <h2>kaXmlOverlay.js</h2>
	
</center>

	


<h4>Summary</h4>
<p>
	
		No overview generated for 'kaXmlOverlay.js'<BR/><BR/>
	
</p>

<hr>


    <table border="1" cellpadding="3" cellspacing="0" width="100%">
    <tr bgcolor="#CCCCFF" class="TableHeadingColor">
    <td colspan=2><font size="+2">
    
        <b>Class Summary</b>
    
    </font></td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="_BrowserIdent.html">_BrowserIdent</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="kaXmlFeature.html">kaXmlFeature</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="kaXmlGraphicElement.html">kaXmlGraphicElement</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="kaXmlIcon.html">kaXmlIcon</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="kaXmlLabel.html">kaXmlLabel</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="kaXmlLinestring.html">kaXmlLinestring</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="kaXmlOverlay.html">kaXmlOverlay</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="kaXmlPoint.html">kaXmlPoint</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="kaXmlPolygon.html">kaXmlPolygon</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    <tr bgcolor="white" class="TableRowColor">
    <td width="15%"><b><a href="kaXmlSymbol.html">kaXmlSymbol</a></b></td>
    <td>&nbsp;</td>
    </tr>
    
    </table>
    <hr/> 


<!-- ========== METHOD SUMMARY =========== -->

	<a name="method_summary"><!-- --></a>
	<table border="1" cellpadding="3" cellspacing="0" width="100%">
		<tr bgcolor="#CCCCFF" class="TableHeadingColor">
			<td colspan=2>
				<font size="+2">
					<b>Method Summary</b>
				</font>
			</td>
		</tr>
	
		
		   <tr bgcolor="white" class="TableRowColor">
		      <td align="right" valign="top" width="1%">
			 <font size="-1">
			    <code>static&nbsp;Object</code>
			 </font>
		      </td>
		      <td>
			 <code>
			    <b>
			       <a href="GLOBALS.html#!s!loadXMLDoc">loadXMLDoc</a></b>(url)
			 </code>
			 <br>
			 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			 retrieve XML document as document object


		      </td>
		   </tr>
		
	
	</table>
    <p>

<!-- ========== END METHOD SUMMARY =========== -->


        <pre class="sourceview"><span class="comment">/******************************************************************************
 * kaXmlOverlay - XML server side generated overlay for kaMap.
 *
 * Piergiorgio Navone 
 *
 * $Id: overview-summary-kaXmlOverlay.js.html,v 1.1 2006/03/15 15:56:59 pspencer Exp $
 *****************************************************************************/</span>
 
<span class="comment">/******************************************************************************
 * BEGIN section in Wiki syntax
 
!!! kaXmlOverlay Quick HOW-TO

* __1__ Import scripts in your page:

 &lt;script type="text/javascript" src="wz_jsgraphics.js"&gt;&lt;/script&gt;
 &lt;script type="text/javascript" src="kaXmlOverlay.js"&gt;&lt;/script&gt;

* __2__ Let ka-Map initialize itself: the next steps should wait at lest the KAMAP_MAP_INITIALIZED event.

* __3__ Create a kaXmlOverlay object:

 myXmlOverlay = new kaXmlOverlay( myKaMap, 250 );

* __4__ Add some objects on the overlay layer. There are two ways to do that

** Call the loadXml method: this method load an XML document from the web server.

 myXmlOverlay.loadXml('points.xml');

** Write a JavaScript function to add your objects:

 var my_point = myXmlOverlay.addNewPoint('Point ID', longuitude, latitude);
 var my_symbol = new kaXmlSymbol();
 my_symbol.size = 12;
 my_symbol.color = '#ff0000';
 my_point.addGraphic(my_symbol);


* __5__ To have a periodic update:

 myInterval = setInterval("myMovingOverlay.loadXml('xmlget.php')",5000);


--------------------------------------------

!!! kaXmlOverlay Reference

This document describe the interface of the JavaScript kaXmlOverlay library as well as the XLM documents describing overlays. The document is divided in tree sections:

# A summary of JavaScript objects and functions
# The definition of the XML
# An in deep description of attributes common to both XML and JavaScript functions


!! JavaScript API

In this section there is a list of main classes with methods an properties that you ca use to programmatically add overlays to your map.
A detailed an updated documentation for each function is maintained as JavaDoc like comments in the source code.


! Class kaXmlOverlay

This class represent a map layer where is possible to add overlays.
To instantiate this class use the constructor
 
 kaXmlOverlay( oKaMap, xml_url )
;oKaMap: A kaMap object
;zIndex: The z index of the layer


To load an XML document with overlay description call the method

 kaXmlOverlay.prototype.loadXml = function(xml_url)
;xml_url: URL of th XML with points to plot


To add a new point to an overlay

 kaXmlOverlay.prototype.addNewPoint = function(pid, x, y)
;pid: Point ID
;x: X geo-coordinate
;y: Y geo-coordinate
;return: A kaXmlPoint object with the given point ID.


To retrieve an existing point from an overlay call

 kaXmlOverlay.prototype.getPointObject = function(pid)
;pid: Point ID
;return: The kaXmlPoint object given the point ID. null if not found.


To remove one or more points from the overlay

kaXmlOverlay.prototype.removePoint = function( pid )
;pid: Point ID or a regexp. If pid is null or not present remove all points.


! Class kaXmlPoint
A kaXmlPoint represents a group of graphic object on the overlay layer. The point is placed on the map at specified geographic coordinates. A point can be moved on the map without the need of redrawing all its graphic objects. 

To instantiate a new point don't use the constructor but call the ''kaXmlOverlay.addNewPoint()'' function.


To place or move a kaXmlPoint on the map call

 kaXmlPoint.prototype.setPosition = function( x, y )
;x: X geo-coordinate
;y: Y geo-coordinate


To clear all graphics associated with the point call the method

 kaXmlPoint.prototype.clear = function()


To add graphic objects to a point use the method

 kaXmlPoint.prototype.addGraphic = function( obj )
;obj: an object of type kaXmlSymbol, kaXmlIcon, kaXmlLabel, kaXmlLinestring or kaXmlPolygon


To manually set the HTML content of a kaXmlPoint use the method

 kaXmlPoint.prototype.setInnerHtml = function(ihtml)
;ihtml: A string containing the HTML

This function delete any other content of the point.


! Graphic objects classes
The graphic objects that can be displayed are:

* kaXmlSymbol
* kaXmlLabel
* kaXmlIcon
* kaXmlLinestring
* kaXmlPolygon

All this classes have a constructor without parameters and different attributes: the attributes are described in the following of the document.

To use one of these objects create a new instance, configure it setting its properties ad add it to a ''kaXmlPoint'' with the method ''addGraphic''.




!! XML Document Type Definition

----------


 &lt;!ELEMENT overlay (delete*, point*)&gt;
 
 &lt;!-- 
 	Delete from the overlay layer one or more points. If the atribute 'id' is present it's 
 	used as a regular expression to match point id to be deleted. If 'id' is not given 
 	deletes all points.
 --&gt;
 &lt;!ELEMENT delete EMPTY&gt;
 
 &lt;!--
 	Define a point with a given ID. If the ID exists it's moved to the new position
 	otherwise it is drawn on the map.
 	In order to redraw an existing point to change some attribute in the rendering
 	let include the attribute redraw="true" or a &lt;delete&gt; element. 
  --&gt;
 &lt;!ELEMENT point (ihtml?, symbol*, icon*, label*, linestring*, polygon*)&gt;
 
 &lt;!-- 
 	Insert arbitrary HTML in the point DIV.
 --&gt;
 &lt;!ELEMENT ihtml (#PCDATA)&gt;
 
 
 &lt;!ELEMENT symbol EMPTY&gt;
 &lt;!ELEMENT icon EMPTY&gt;


 &lt;!-- 
 	The content of the label element is the text of label.
 --&gt;
 &lt;!ELEMENT label (#PCDATA)&gt;

 &lt;!-- 
 	The content of the linestring element is a list of coordinates in the form:
 		x0 y0, x1 y1, [...], xn yn
 --&gt;
 &lt;!ELEMENT linestring EMPTY&gt;
 
 &lt;!-- 
 	The content of the polygon element is a list of coordinates in the form:
 		x0 y0, x1 y1, [...], xn yn
 --&gt;
 &lt;!ELEMENT polygon EMPTY&gt;
 
 &lt;!ATTLIST delete id CDATA #IMPLIED&gt;
 
 &lt;!ATTLIST point id CDATA #REQUIRED&gt;
 &lt;!ATTLIST point x CDATA #REQUIRED&gt;
 &lt;!ATTLIST point y CDATA #REQUIRED&gt;
 &lt;!ATTLIST point redraw (false|true) "false"&gt;
 
 &lt;!ATTLIST symbol shape CDATA #IMPLIED&gt;
 &lt;!ATTLIST symbol size CDATA #IMPLIED&gt;
 &lt;!ATTLIST symbol color CDATA #IMPLIED&gt;
 &lt;!ATTLIST symbol opacity CDATA #IMPLIED&gt;
 
 &lt;!ATTLIST icon src CDATA #REQUIRED&gt;
 &lt;!ATTLIST icon w CDATA #REQUIRED&gt;
 &lt;!ATTLIST icon h CDATA #REQUIRED&gt;
 &lt;!ATTLIST icon px CDATA #IMPLIED&gt;
 &lt;!ATTLIST icon py CDATA #IMPLIED&gt;
 &lt;!ATTLIST icon opacity CDATA #IMPLIED&gt;
 
 &lt;!ATTLIST label color CDATA #IMPLIED&gt;
 &lt;!ATTLIST label boxcolor CDATA #IMPLIED&gt;
 &lt;!ATTLIST label w CDATA #IMPLIED&gt;
 &lt;!ATTLIST label h CDATA #IMPLIED&gt;
 &lt;!ATTLIST label px CDATA #IMPLIED&gt;
 &lt;!ATTLIST label py CDATA #IMPLIED&gt;
 &lt;!ATTLIST label fsize CDATA #IMPLIED&gt;
 &lt;!ATTLIST label font CDATA #IMPLIED&gt;
 
 &lt;!ATTLIST linestring color CDATA #IMPLIED&gt;
 &lt;!ATTLIST linestring stroke CDATA #IMPLIED&gt;
 &lt;!ATTLIST linestring opacity CDATA #IMPLIED&gt;

 &lt;!ATTLIST polygon color CDATA #IMPLIED&gt;
 &lt;!ATTLIST polygon bcolor CDATA #IMPLIED&gt;
 &lt;!ATTLIST polygon stroke CDATA #IMPLIED&gt;
 &lt;!ATTLIST polygon opacity CDATA #IMPLIED&gt;

----------


! XML document example

----------
 TODO
----------

!! Overlay objects attributes

! POINT (&lt;point&gt;)
The POINT is the father of all objects you can display on the overlay layer.
Wherever you want dislay someting on the overlay layer you have to define a
POINT than add to the POINT icons, symbols, labels, etc.

__POINT attributes:__

;id: (string, mandatory) This string is used to identify the point. It's needed to translate, delete, redraw the POINT.
;x: (number, required) The X coordinate in map units.
;y: (number, required) The Y coordinate in map units.


! SYMBOL (kaXmlSymbol, &lt;symbol&gt;)
A symbol is a graphic element drawn at POINT coordinates. It's similar to an icon, but it has a parametric color and size.

__SYMBOL attributes:__

;shape: (string, optional) The shape of the symbol. Today implementation allow only the shape ''bullet''.
;color: (string, optional) The color of the symbol (HTML syntax).
;size: (integer, optional) The size in pixels of the symbol.
;opacity: (number, optional) 1.0 is opaque, 0.0 is fully transparent.


! ICON (kaXmlIcon, &lt;icon&gt;)
An icon drawn at POINT coordinates. The image is defined with an URL. Width and height of the image must be provided, because the icon will be centred at POINT coordinates.

__ICON attributes__

;src: (string, required) The relative or absolute URL of the image
;w: (integer, required) Width of the image in pixels
;h: (integer, required) Height of the image in pixels
;px: (integer, optional) Horizontal offset in pixels (positive to move the icon on the right).
;py: (integer, optional) Vertical offset in pixels (negative to rise the icon).
;opacity: (number, optional) 1.0 is opaque, 0.0 is fully transparent.

! LABEL (kaXmlLabel, &lt;label&gt;)
A text label is written near the POINT. POINT coordinates represent the top-left corner of the LABEL.

__LABEL attributes__ (Preliminary)

;color: (string, optional) Text color (HTML syntax).
;boxcolor: (string, optional) Background color behind the text (HTML syntax).
;w: (integer, optional) Width of the label in pixels.
;h: (integer, optional) Height of the label in pixels.
;px: (integer, optional) Horizontal offset in pixels (positive to move the label on the right).
;py: (integer, optional) Vertical offset in pixels (negative to rise the label).
;font: (string, optional) The text font (HTML syntax).
;fsize: (string, optional) Font size (HTML syntax).
;text: (string, required) The label text: this attribute is present only in JavaScript: in the XML syntax the text is the content of the &lt;label&gt; element.


! LINESTRING (kaXmlLinestring, &lt;linestring&gt;)
This element represent a geographic feature, a single line in geographic coordinates that will be scaled with the map.

__LINESTRING attributes__

;color: (string, optional) Line color (HTML syntax).
;stroke: (integer, optional) Line width in pixels.
;opacity: (number, optional) 1.0 is opaque, 0.0 is fully transparent.


! POLYGON (kaXmlPolygon, &lt;polygon&gt;)
This element represent a geographic feature, a single polygon in geographic coordinates that will be scaled with the map.

__POLYGON attributes__

;color: (string, optional) Surface color (HTML syntax).
;bcolor: (string, optional) Border color (HTML syntax).
;stroke: (integer, optional) Border width in pixels.
;opacity: (number, optional) 1.0 is opaque, 0.0 is fully transparent.

---------------------------------------------------

!!! FAQs

__Error: xmlDocument has no properties__

;: The XML is served with a wrong mime type by your web server. It should have a mime type "text/xml". Configure your server to associate ".xml" files with the correct mime, or, if you generate the XML dynamically, use a directive to set the mime type.



---------------------------------------------------

!!! TODOs
* Add a query capability for overlay points
* Evaluate the use of custom onclick or ondblclick events on points
* Add a tooltip for overlay points
* Make the label management smarter

 
 * END section in Wiki syntax
 *****************************************************************************/</span>

<span class="comment">/**
 * kaXmlOverlay( oKaMap, xml_url )
 *
 * oKaMap 	A kaMap object
 * zIndex	The z index of the layer
 */</span>
<span class="reserved">function</span> kaXmlOverlay( oKaMap, zIndex )
{
    kaTool.apply( <span class="reserved">this</span>, [oKaMap] );
    <span class="reserved">this</span>.name = <span class="literal">'kaXmlOverlay'</span>;

    <span class="reserved">for</span> (var p in kaTool.<span class="reserved">prototype</span>)
    {
        <span class="reserved">if</span> (!kaXmlOverlay.<span class="reserved">prototype</span>[p]) 
            kaXmlOverlay.<span class="reserved">prototype</span>[p]= kaTool.<span class="reserved">prototype</span>[p];
    }
    
    <span class="reserved">this</span>.browser = new _BrowserIdent();
    
    <span class="reserved">this</span>.urlBase = <span class="reserved">this</span>.kaMap.server;
    <span class="reserved">this</span>.urlBase += (<span class="reserved">this</span>.urlBase!=<span class="literal">''</span>&amp;&amp;<span class="reserved">this</span>.urlBase.substring(-1)!=<span class="literal">'/'</span>)?<span class="literal">''</span>:<span class="literal">'/'</span>;

	<span class="comment">// The list of overlay points</span>
	<span class="reserved">this</span>.ovrObjects = new Array();   
	
	<span class="comment">// The cavas of the overlay layer</span>
	<span class="reserved">this</span>.z_index = zIndex;
	<span class="reserved">this</span>.overlayCanvas = <span class="reserved">this</span>.kaMap.createDrawingCanvas( zIndex );
	
	<span class="comment">// Register for events</span>
    <span class="reserved">this</span>.kaMap.registerForEvent( KAMAP_SCALE_CHANGED, <span class="reserved">this</span>, <span class="reserved">this</span>.scaleChanged );
	
}

kaXmlOverlay.<span class="reserved">prototype</span>.scaleChanged = <span class="reserved">function</span>( eventID, mapName ) {
	<span class="reserved">if</span> (<span class="reserved">this</span>.ovrObjects == null) <span class="reserved">return</span>;
	<span class="reserved">for</span> (var i=0; i &lt; <span class="reserved">this</span>.ovrObjects.length; i++) {
		<span class="reserved">this</span>.ovrObjects[i].rescale();
	}
}

<span class="comment">/**
 * Remove the overlay layer and free resources user by overlay objects.
 */</span>
kaXmlOverlay.<span class="reserved">prototype</span>.remove = <span class="reserved">function</span>() {
    <span class="reserved">this</span>.kaMap.deregisterForEvent( KAMAP_SCALE_CHANGED, <span class="reserved">this</span>, <span class="reserved">this</span>.scaleChanged );
	<span class="reserved">this</span>.removePoint();
	<span class="reserved">this</span>.kaMap.removeDrawingCanvas(<span class="reserved">this</span>.overlayCanvas);
}

<span class="comment">/**
 * Load XML from the server and update the overlay.
 *
 * xml_url	URL of th XML with points to plot
 */</span>
kaXmlOverlay.<span class="reserved">prototype</span>.loadXml = <span class="reserved">function</span>(xml_url) {
    <span class="reserved">this</span>.urlBase = <span class="reserved">this</span>.kaMap.server;
    <span class="reserved">this</span>.urlBase += (<span class="reserved">this</span>.urlBase!=<span class="literal">''</span>&amp;&amp;<span class="reserved">this</span>.urlBase.substring(-1)!=<span class="literal">'/'</span>)?<span class="literal">''</span>:<span class="literal">'/'</span>;

	<span class="comment">// The URL of the XML</span>
	<span class="reserved">this</span>.xmlOvrUrl = <span class="reserved">this</span>.urlNormalize(xml_url);
	
	var xmlDocument = loadXMLDoc(<span class="reserved">this</span>.xmlOvrUrl);
	var objDomTree = xmlDocument.documentElement;
	
	var dels = objDomTree.getElementsByTagName(<span class="literal">"delete"</span>);
	<span class="reserved">for</span> (var i=0; i&lt;dels.length; i++) {
		<span class="comment">// read the id attribute</span>
		var a_id = dels[i].getAttributeNode(<span class="literal">"id"</span>);
		<span class="reserved">if</span> (a_id == null) {
			<span class="comment">// delete all points</span>
			<span class="reserved">this</span>.removePoint();
		} <span class="reserved">else</span> {
			<span class="reserved">this</span>.removePoint(a_id.value);
		}
	}
	
	var need_update = false;
		
	var points = objDomTree.getElementsByTagName(<span class="literal">"point"</span>);
	<span class="reserved">for</span> (var i=0; i&lt;points.length; i++) {
		<span class="comment">// read the mandatory attributes</span>
		var a_pid = points[i].getAttributeNode(<span class="literal">"id"</span>);
		<span class="reserved">if</span> (a_pid == null) {
			continue;
		}
		var pid = a_pid.value;
				
		var np = <span class="reserved">this</span>.getPointObject(pid);
		<span class="reserved">if</span> (np == null) {
			<span class="comment">// Create a new point</span>
			np = new kaXmlPoint(pid,<span class="reserved">this</span>);
			<span class="reserved">this</span>.ovrObjects.push(np);
		}

		np.parse(points[i]);
		need_update = true;
	}
	
	<span class="reserved">if</span> (need_update) <span class="reserved">this</span>.kaMap.updateObjects();
}

<span class="comment">/**
 * 
 */</span>
kaXmlOverlay.<span class="reserved">prototype</span>.urlNormalize = <span class="reserved">function</span>(url) {
	<span class="reserved">if</span> (url == null) <span class="reserved">return</span> <span class="literal">""</span>;
	<span class="reserved">if</span> (url.substring(1)!=<span class="literal">'/'</span>) {
		<span class="reserved">return</span> <span class="reserved">this</span>.urlBase+url;
	}
	<span class="reserved">return</span> url;
}
 
<span class="comment">/**
 * pid		Point ID
 * return The DIV object of the given point ID. null if not found.
 */</span>
kaXmlOverlay.<span class="reserved">prototype</span>.getDiv = <span class="reserved">function</span>(pid) {
	var div_id = <span class="reserved">this</span>.getDivId(pid);
	<span class="reserved">return</span> getRawObject(div_id);
}

<span class="comment">/**
 * pid		Point ID
 * return The kaXmlPoint object given the point ID. null if not found.
 */</span>
kaXmlOverlay.<span class="reserved">prototype</span>.getPointObject = <span class="reserved">function</span>(pid) {
	<span class="reserved">for</span> (var i=0; i &lt; <span class="reserved">this</span>.ovrObjects.length; i++) {
		<span class="reserved">if</span> (<span class="reserved">this</span>.ovrObjects[i] != null &amp;&amp; <span class="reserved">this</span>.ovrObjects[i].pid == pid) {
			<span class="reserved">return</span> <span class="reserved">this</span>.ovrObjects[i];
	 	}
	}
	<span class="reserved">return</span> null;
}

<span class="comment">/**
 * Instantiate a new kaXmlPoint adn add it to the overlay. If the PID
 * already exists it's deleted and recreated.
 *
 * pid		Point ID
 * x			X Coordinate
 * y			Y Coordinate
 * return A kaXmlPoint object with the given point ID.
 */</span>
kaXmlOverlay.<span class="reserved">prototype</span>.addNewPoint = <span class="reserved">function</span>(pid,x,y) {
	<span class="reserved">this</span>.removePoint(pid);
	var np = new kaXmlPoint(pid,<span class="reserved">this</span>);
	np.placeOnMap(x,y);
	<span class="reserved">this</span>.ovrObjects.push(np);
	<span class="reserved">return</span> np;
}

<span class="comment">/**
 * pid		Point ID
 * return the DIV id given the point ID
 */</span>
kaXmlOverlay.<span class="reserved">prototype</span>.getDivId = <span class="reserved">function</span>(pid) {
	<span class="reserved">return</span> <span class="literal">'xmlovr_'</span>+pid+<span class="literal">'_div'</span>;
}

<span class="comment">/**
 * Remove one or more point div from the map.
 * If pid is null or not present remove all points.
 *
 * pid		Point ID or a regexp 
 */</span>
kaXmlOverlay.<span class="reserved">prototype</span>.removePoint = <span class="reserved">function</span>( pid ) {

	<span class="reserved">if</span> ( (<span class="reserved">this</span>.removePoint.arguments.length &lt; 1) || (pid == null) ) {
		<span class="reserved">for</span> (var i=0; i &lt; <span class="reserved">this</span>.ovrObjects.length; i++) {
			<span class="reserved">if</span> (<span class="reserved">this</span>.ovrObjects[i] != null) {
				<span class="reserved">this</span>.ovrObjects[i].removeFromMap();
				delete <span class="reserved">this</span>.ovrObjects[i];
				<span class="reserved">this</span>.ovrObjects[i] = null;
			}
			delete <span class="reserved">this</span>.ovrObjects[i];
		}
		<span class="reserved">return</span>;
	}
	
	var re = new RegExp(pid);
	<span class="reserved">for</span> (var i=0; i &lt; <span class="reserved">this</span>.ovrObjects.length; i++) {
		<span class="reserved">if</span> (re.test(<span class="reserved">this</span>.ovrObjects[i].pid)) {
			<span class="reserved">if</span> (<span class="reserved">this</span>.ovrObjects[i] != null) {
				<span class="reserved">this</span>.ovrObjects[i].removeFromMap();
				delete <span class="reserved">this</span>.ovrObjects[i];
				<span class="reserved">this</span>.ovrObjects[i] = null;
			}
			delete <span class="reserved">this</span>.ovrObjects[i];
	 	}
	}
}
 
<span class="comment">/**
 * retrieve XML document as document object
 *
 * url		The XML URL
 * return 	The XML document object
 */</span>
<span class="reserved">function</span> loadXMLDoc(url) {
	<span class="comment">// XML document</span>
	var xDoc;
	var req;
	<span class="reserved">if</span> (window.XMLHttpRequest) {
		req = new XMLHttpRequest();
		req.open(<span class="literal">"GET"</span>, url, false);
		req.send(null);
	} <span class="reserved">else</span> <span class="reserved">if</span> (window.ActiveXObject) {
		req = new ActiveXObject(<span class="literal">"Microsoft.XMLHTTP"</span>);
		<span class="reserved">if</span> (req) {
			req.open(<span class="literal">"GET"</span>, url, false);
			req.send();
		}
	}
	<span class="reserved">if</span> (req) {
		<span class="reserved">if</span> (req.status == 200) {
			xDoc = req.responseXML;
			<span class="reserved">if</span> (xDoc &amp;&amp; typeof xDoc.childNodes != <span class="literal">"undefined"</span> &amp;&amp;
				xDoc.childNodes.length == 0) {
				xDoc = null;
			}
		} <span class="reserved">else</span> {
			alert(<span class="literal">"There was a problem retrieving the XML data:\n"</span> + req.statusText);
		}
	} <span class="reserved">else</span> {
		alert(<span class="literal">"Sorry, this browser isn't equipped to read XML data."</span>);
	}
	
	<span class="reserved">return</span> xDoc;
}



<span class="comment">/**
 * Base class for all graphics elements.
 */</span>
<span class="reserved">function</span> kaXmlGraphicElement() {}

<span class="comment">/**
 * Initialize the graphics element from an XML element
 *
 * point			The parent kaXmlPoint object
 * domElement	The XML DOM element that describe the graphic
 */</span>
kaXmlGraphicElement.<span class="reserved">prototype</span>.parseElement = <span class="reserved">function</span>(point, domElement) {}

<span class="comment">/**
 * Draw the graphics element
 *
 * point		The parent kaXmlPoint object
 */</span>
kaXmlGraphicElement.<span class="reserved">prototype</span>.draw = <span class="reserved">function</span>(point) {}

<span class="comment">/**
 * Draw the graphics element
 *
 * point		The parent kaXmlPoint object
 */</span>
kaXmlGraphicElement.<span class="reserved">prototype</span>.rescale = <span class="reserved">function</span>(point) {}


<span class="comment">/**
 * Construct a symbol 
 */</span>
<span class="reserved">function</span> kaXmlSymbol() {
	kaXmlGraphicElement.apply(<span class="reserved">this</span>);
    <span class="reserved">for</span> (var p in kaXmlGraphicElement.<span class="reserved">prototype</span>) {
        <span class="reserved">if</span> (!kaXmlSymbol.<span class="reserved">prototype</span>[p]) 
            kaXmlSymbol.<span class="reserved">prototype</span>[p]= kaXmlGraphicElement.<span class="reserved">prototype</span>[p];
    }
	
	<span class="reserved">this</span>.shape = <span class="literal">"bullet"</span>;
	<span class="reserved">this</span>.size = 10;
	<span class="reserved">this</span>.color = <span class="literal">"black"</span>;
}

kaXmlSymbol.<span class="reserved">prototype</span>.parseElement = <span class="reserved">function</span>(point, domElement) {
	<span class="reserved">this</span>.shape = domElement.getAttribute(<span class="literal">"shape"</span>);
	<span class="reserved">this</span>.size = parseInt(domElement.getAttribute(<span class="literal">"size"</span>));
	var c = domElement.getAttribute(<span class="literal">"color"</span>);
	<span class="reserved">if</span> (c != null) <span class="reserved">this</span>.color = c;
}

kaXmlSymbol.<span class="reserved">prototype</span>.draw = <span class="reserved">function</span>(point) {
	var jsgObject = new jsGraphics(point.divId); 
	with (jsgObject) {
		setColor(<span class="reserved">this</span>.color);
		var d = <span class="reserved">this</span>.size / 2;     
		fillEllipse(-d, -d, <span class="reserved">this</span>.size, <span class="reserved">this</span>.size);
		paint();
	}
}

<span class="comment">/**
 * Construct a geographic feature
 */</span>
<span class="reserved">function</span> kaXmlFeature( point ) {
	kaXmlGraphicElement.apply(<span class="reserved">this</span>);
    <span class="reserved">for</span> (var p in kaXmlGraphicElement.<span class="reserved">prototype</span>) {
        <span class="reserved">if</span> (!kaXmlFeature.<span class="reserved">prototype</span>[p]) 
            kaXmlFeature.<span class="reserved">prototype</span>[p]= kaXmlGraphicElement.<span class="reserved">prototype</span>[p];
    }
    
    <span class="reserved">this</span>.stroke = 1;
    <span class="reserved">this</span>.color = null;
    <span class="reserved">this</span>.bcolor = null;
    <span class="reserved">this</span>.opacity = 1;

	<span class="reserved">this</span>.cxmin = 0;
	<span class="reserved">this</span>.cymax = 0;
	<span class="reserved">this</span>.coords = <span class="literal">""</span>;
	<span class="reserved">this</span>.img = null;
	
	<span class="comment">// Calculate the min cellSize</span>
	var map = point.xml_overlay.kaMap.getCurrentMap();
	var scales = map.getScales();
	<span class="reserved">this</span>.maxScale = scales[scales.length - 1];
	<span class="reserved">this</span>.mcs = point.xml_overlay.kaMap.cellSize / point.xml_overlay.kaMap.getCurrentScale() * <span class="reserved">this</span>.maxScale;
}
	
kaXmlFeature.<span class="reserved">prototype</span>.parseElement = <span class="reserved">function</span>(point, domElement) {
	var t;
	t = parseInt(domElement.getAttribute(<span class="literal">"stroke"</span>));
	<span class="reserved">if</span> (! isNaN(t)) <span class="reserved">this</span>.stroke = t;
	t = domElement.getAttribute(<span class="literal">"color"</span>);
	<span class="reserved">if</span> (t != null) <span class="reserved">this</span>.color = t;
	t = domElement.getAttribute(<span class="literal">"bcolor"</span>);
	<span class="reserved">if</span> (t != null) <span class="reserved">this</span>.bcolor = t;
	t = parseFloat(domElement.getAttribute(<span class="literal">"opacity"</span>));
	<span class="reserved">if</span>(! isNaN(t)) <span class="reserved">this</span>.opacity = t; 
	
	var text = <span class="literal">""</span>;
	<span class="reserved">if</span> (domElement.firstChild != null) {
		text = domElement.firstChild.data;
		<span class="reserved">this</span>.readCoordinates(point, text)	;	
	}
}

kaXmlFeature.<span class="reserved">prototype</span>.readCoordinates = <span class="reserved">function</span>(point, text) {
	var cx = new Array();
	var cy = new Array();
	<span class="reserved">this</span>.cxmin = 0;
	<span class="reserved">this</span>.cymax = 0;
	<span class="reserved">this</span>.coords = <span class="literal">""</span>;
	var pp = text.split(<span class="literal">','</span>);
	var i;
	<span class="reserved">for</span> (i=0; i&lt;pp.length; i++) {
		var s = pp[i];
		var xy = s.match(/[-\+\d\.]+/g);
		<span class="reserved">if</span> (xy != null) {
			var x=parseFloat(xy[0]);
			var y=parseFloat(xy[1]);
			cx.push(x);
			cy.push(y);
			<span class="reserved">if</span> (i==0 || x&lt;<span class="reserved">this</span>.cxmin) <span class="reserved">this</span>.cxmin = x;
			<span class="reserved">if</span> (i==0 || y&gt;<span class="reserved">this</span>.cymax) <span class="reserved">this</span>.cymax = y;
		}
	}
	
	<span class="comment">// Normalize the coordinates</span>
	<span class="reserved">for</span> (i=0; i&lt;pp.length; i++) {
		var x = Math.round((cx[i] - <span class="reserved">this</span>.cxmin) / <span class="reserved">this</span>.mcs);
		var y = Math.round((<span class="reserved">this</span>.cymax - cy[i]) / <span class="reserved">this</span>.mcs);
		<span class="reserved">if</span> (i&gt;0) <span class="reserved">this</span>.coords += <span class="literal">","</span>;
			<span class="reserved">this</span>.coords += x+<span class="literal">","</span>+y;
	}
}

<span class="comment">/**
 * Construct a linestring 
 */</span>
<span class="reserved">function</span> kaXmlLinestring( point ) {
	kaXmlFeature.apply(<span class="reserved">this</span>, [point]);
    <span class="reserved">for</span> (var p in kaXmlFeature.<span class="reserved">prototype</span>) {
        <span class="reserved">if</span> (!kaXmlLinestring.<span class="reserved">prototype</span>[p]) 
            kaXmlLinestring.<span class="reserved">prototype</span>[p]= kaXmlFeature.<span class="reserved">prototype</span>[p];
    }
}

kaXmlLinestring.<span class="reserved">prototype</span>.draw = <span class="reserved">function</span>(point) {
	var xy = point.xml_overlay.kaMap.geoToPix( <span class="reserved">this</span>.cxmin, <span class="reserved">this</span>.cymax );
	var x0 = xy[0];
	var y0 = xy[1];
	
	xy = point.xml_overlay.kaMap.geoToPix( point.div.lon, point.div.lat );
	var xr = xy[0];
	var yr = xy[1];
	
	var border = 5;
	
	<span class="reserved">if</span> (<span class="reserved">this</span>.img == null) {
    		<span class="reserved">this</span>.img = document.createElement( <span class="literal">'img'</span> );
	    point.div.appendChild( <span class="reserved">this</span>.img );
	    <span class="reserved">this</span>.img.style.position = <span class="literal">'absolute'</span>;
	}
	
    <span class="reserved">this</span>.img.style.top = (y0 - yr - border)+<span class="literal">'px'</span>;
    <span class="reserved">this</span>.img.style.left = (x0 - xr - border)+<span class="literal">'px'</span>;
    var scf = point.xml_overlay.kaMap.getCurrentScale() / <span class="reserved">this</span>.maxScale;
    var it = point.xml_overlay.browser.getPreferredImageType();
    var u = <span class="literal">"drawgeom.php?gt=L&amp;st="</span>+<span class="reserved">this</span>.stroke+<span class="literal">"&amp;bp="</span>+border+<span class="literal">"&amp;sc="</span>+scf+<span class="literal">"&amp;cl="</span>+<span class="reserved">this</span>.coords;
    <span class="reserved">if</span> (<span class="reserved">this</span>.color != null) u += <span class="literal">"&amp;lc="</span>+escape(<span class="reserved">this</span>.color);
    <span class="reserved">if</span> (it == <span class="literal">"P"</span>) {
    		u += <span class="literal">"&amp;it=P"</span>;
    } <span class="reserved">else</span> {
    		u += <span class="literal">"&amp;it=G"</span>;
    }
    <span class="reserved">if</span> (point.xml_overlay.browser.getPreferredOpacity() == <span class="literal">"server"</span>) {
    		<span class="reserved">if</span> (<span class="reserved">this</span>.opacity &lt; 1) u += <span class="literal">"&amp;op="</span>+(<span class="reserved">this</span>.opacity*100);
    } <span class="reserved">else</span> {
    		<span class="reserved">if</span> (<span class="reserved">this</span>.opacity &lt; 1) point.xml_overlay.browser.setOpacity(<span class="reserved">this</span>.img, <span class="reserved">this</span>.opacity);
    }
    <span class="reserved">this</span>.img.src = u;
}

kaXmlLinestring.<span class="reserved">prototype</span>.rescale = <span class="reserved">function</span>(point) {
	<span class="reserved">this</span>.draw(point);
}

<span class="comment">/**
 * Construct a Polygon from the XML element
 */</span>
<span class="reserved">function</span> kaXmlPolygon( point ) {
	kaXmlFeature.apply(<span class="reserved">this</span>, [point]);
    <span class="reserved">for</span> (var p in kaXmlFeature.<span class="reserved">prototype</span>) {
        <span class="reserved">if</span> (!kaXmlPolygon.<span class="reserved">prototype</span>[p]) 
            kaXmlPolygon.<span class="reserved">prototype</span>[p]= kaXmlFeature.<span class="reserved">prototype</span>[p];
    }
}

kaXmlPolygon.<span class="reserved">prototype</span>.draw = <span class="reserved">function</span>(point) {
	var xy = point.xml_overlay.kaMap.geoToPix( <span class="reserved">this</span>.cxmin, <span class="reserved">this</span>.cymax );
	var x0 = xy[0];
	var y0 = xy[1];
	
	xy = point.xml_overlay.kaMap.geoToPix( point.div.lon, point.div.lat );
	var xr = xy[0];
	var yr = xy[1];
	
	var border = 5;
	
	<span class="reserved">if</span> (<span class="reserved">this</span>.img == null) {
    		<span class="reserved">this</span>.img = document.createElement( <span class="literal">'img'</span> );
	    <span class="reserved">this</span>.img.style.position = <span class="literal">'absolute'</span>;
	    point.div.appendChild( <span class="reserved">this</span>.img );
	}
	
    var scf = point.xml_overlay.kaMap.getCurrentScale() / <span class="reserved">this</span>.maxScale;
    var it = point.xml_overlay.browser.getPreferredImageType();
    var u = <span class="literal">"drawgeom.php?gt=P&amp;st="</span>+<span class="reserved">this</span>.stroke+<span class="literal">"&amp;bp="</span>+border+<span class="literal">"&amp;sc="</span>+scf+<span class="literal">"&amp;cl="</span>+<span class="reserved">this</span>.coords;
    <span class="reserved">if</span> (<span class="reserved">this</span>.color != null) u += <span class="literal">"&amp;fc="</span>+escape(<span class="reserved">this</span>.color);
    <span class="reserved">if</span> (<span class="reserved">this</span>.bcolor != null &amp;&amp; <span class="reserved">this</span>.bcolor != <span class="literal">""</span>) u += <span class="literal">"&amp;lc="</span>+escape(<span class="reserved">this</span>.bcolor);
    <span class="reserved">if</span> (it == <span class="literal">"P"</span>) {
    		u += <span class="literal">"&amp;it=P"</span>;
    } <span class="reserved">else</span> {
    		u += <span class="literal">"&amp;it=G"</span>;
    }
    <span class="reserved">if</span> (point.xml_overlay.browser.getPreferredOpacity() == <span class="literal">"server"</span>) {
    		<span class="reserved">if</span> (<span class="reserved">this</span>.opacity &lt; 1) u += <span class="literal">"&amp;op="</span>+(<span class="reserved">this</span>.opacity*100);
    } <span class="reserved">else</span> {
    		<span class="reserved">if</span> (<span class="reserved">this</span>.opacity &lt; 1) point.xml_overlay.browser.setOpacity(<span class="reserved">this</span>.img, <span class="reserved">this</span>.opacity);
    }
    
    <span class="reserved">this</span>.img.style.top = (y0 - yr - border)+<span class="literal">'px'</span>;
    <span class="reserved">this</span>.img.style.left = (x0 - xr - border)+<span class="literal">'px'</span>;
    
    <span class="reserved">this</span>.img.src = u;
}

kaXmlPolygon.<span class="reserved">prototype</span>.rescale = <span class="reserved">function</span>(point) {
	<span class="reserved">this</span>.draw(point);
}

<span class="comment">/**
 * Construct a label from the XML element
 */</span>
<span class="reserved">function</span> kaXmlLabel() {
	kaXmlGraphicElement.apply(<span class="reserved">this</span>);
    <span class="reserved">for</span> (var p in kaXmlGraphicElement.<span class="reserved">prototype</span>) {
        <span class="reserved">if</span> (!kaXmlLabel.<span class="reserved">prototype</span>[p]) 
            kaXmlLabel.<span class="reserved">prototype</span>[p]= kaXmlGraphicElement.<span class="reserved">prototype</span>[p];
    }
	
	<span class="reserved">this</span>.text = <span class="literal">""</span>;
	<span class="reserved">this</span>.color = <span class="literal">"black"</span>;
	<span class="reserved">this</span>.boxcolor = null;
	<span class="reserved">this</span>.w = 64;
	<span class="reserved">this</span>.h = 24;
	<span class="reserved">this</span>.xoff = 0;
	<span class="reserved">this</span>.yoff = 0;
	<span class="reserved">this</span>.fsize = <span class="literal">"10px"</span>;
	<span class="reserved">this</span>.font = <span class="literal">"Arial"</span>;
}

kaXmlLabel.<span class="reserved">prototype</span>.parseElement = <span class="reserved">function</span>(point, domElement) {
	<span class="reserved">if</span> (domElement.firstChild != null) {
		<span class="reserved">this</span>.text = domElement.firstChild.data;
	}

	var t;		
	t = domElement.getAttribute(<span class="literal">"color"</span>);
	<span class="reserved">if</span> (t != null) {
		<span class="reserved">this</span>.color = t;
	}
	<span class="reserved">this</span>.boxcolor = domElement.getAttribute(<span class="literal">"boxcolor"</span>);
	t = parseInt(domElement.getAttribute(<span class="literal">"w"</span>));
	<span class="reserved">if</span> (!isNaN(t)) {
		<span class="reserved">this</span>.w = t;
	}
	t = parseInt(domElement.getAttribute(<span class="literal">"h"</span>));
	<span class="reserved">if</span> (!isNaN(t)) {
		<span class="reserved">this</span>.h = t;
	}
	t = parseInt(domElement.getAttribute(<span class="literal">"px"</span>));
	<span class="reserved">if</span> (!isNaN(t)) {
		<span class="reserved">this</span>.xoff = t;
	}
	t = parseInt(domElement.getAttribute(<span class="literal">"py"</span>));
	<span class="reserved">if</span> (!isNaN(t)) {
		<span class="reserved">this</span>.yoff = t;
	}
	t = domElement.getAttribute(<span class="literal">"fsize"</span>);
	<span class="reserved">if</span> (t != null) {
		<span class="reserved">this</span>.fsize = t;
	}
	t = domElement.getAttribute(<span class="literal">"font"</span>);
	<span class="reserved">if</span> (t != null) {
		<span class="reserved">this</span>.font = t;
	}	
}

kaXmlLabel.<span class="reserved">prototype</span>.draw = <span class="reserved">function</span>(point) {
	var x = <span class="reserved">this</span>.xoff;
	var y = <span class="reserved">this</span>.yoff;
	
	var ldiv = document.createElement( <span class="literal">'div'</span> );
	ldiv.style.fontFamily = <span class="reserved">this</span>.font;
	ldiv.style.fontSize = <span class="reserved">this</span>.fsize;
	ldiv.style.textAlign = <span class="literal">'center'</span>;
	ldiv.style.color = <span class="reserved">this</span>.color;
    ldiv.style.left = x+<span class="literal">'px'</span>;
    ldiv.style.top = y+<span class="literal">'px'</span>;
	ldiv.style.position = <span class="literal">'absolute'</span>;
	<span class="reserved">if</span> (<span class="reserved">this</span>.boxcolor != null) ldiv.style.backgroundColor = <span class="reserved">this</span>.boxcolor;
	<span class="reserved">if</span> (<span class="reserved">this</span>.w&gt;0) ldiv.style.width = <span class="reserved">this</span>.w+<span class="literal">'px'</span>;
	<span class="reserved">else</span> ldiv.style.whiteSpace = <span class="literal">'nowrap'</span>;
	<span class="reserved">if</span> (<span class="reserved">this</span>.h&gt;0) ldiv.style.height = <span class="reserved">this</span>.h+<span class="literal">'px'</span>;
	
	var ltxt = document.createTextNode(<span class="reserved">this</span>.text);
	ldiv.appendChild( ltxt );
	
	point.div.appendChild( ldiv );
}

<span class="comment">/**
 * Construct an icon
 */</span>
<span class="reserved">function</span> kaXmlIcon() {
	kaXmlGraphicElement.apply(<span class="reserved">this</span>);
    <span class="reserved">for</span> (var p in kaXmlGraphicElement.<span class="reserved">prototype</span>) {
        <span class="reserved">if</span> (!kaXmlIcon.<span class="reserved">prototype</span>[p]) 
            kaXmlIcon.<span class="reserved">prototype</span>[p]= kaXmlGraphicElement.<span class="reserved">prototype</span>[p];
    }
    
	<span class="reserved">this</span>.icon_src = null;
	<span class="reserved">this</span>.icon_w = 0;
	<span class="reserved">this</span>.icon_h = 0;
	<span class="reserved">this</span>.xoff = 0;
	<span class="reserved">this</span>.yoff = 0;
}

kaXmlIcon.<span class="reserved">prototype</span>.parseElement = <span class="reserved">function</span>(point, domElement) {
	<span class="reserved">this</span>.icon_src = point.xml_overlay.urlNormalize(domElement.getAttribute(<span class="literal">"src"</span>));
	<span class="reserved">this</span>.icon_w = parseInt(domElement.getAttribute(<span class="literal">"w"</span>));
	<span class="reserved">this</span>.icon_h = parseInt(domElement.getAttribute(<span class="literal">"h"</span>));
	var t;
	t = parseInt(domElement.getAttribute(<span class="literal">"px"</span>));
	<span class="reserved">if</span> (!isNaN(t)) {
		<span class="reserved">this</span>.xoff = t;
	}
	t = parseInt(domElement.getAttribute(<span class="literal">"py"</span>));
	<span class="reserved">if</span> (!isNaN(t)) {
		<span class="reserved">this</span>.yoff = t;
	}
}

kaXmlIcon.<span class="reserved">prototype</span>.draw = <span class="reserved">function</span>(point) {
	var dx = -<span class="reserved">this</span>.icon_w / 2 + <span class="reserved">this</span>.xoff;     
	var dy = -<span class="reserved">this</span>.icon_h / 2 + <span class="reserved">this</span>.yoff;     
	
    var idiv = document.createElement( <span class="literal">'div'</span> );
    idiv.style.position = <span class="literal">'absolute'</span>;
    idiv.style.top = dy+<span class="literal">'px'</span>;
    idiv.style.left = dx+<span class="literal">'px'</span>;
    
    var img = document.createElement( <span class="literal">'img'</span> );
    img.src = <span class="reserved">this</span>.icon_src;
    img.width = <span class="reserved">this</span>.icon_w;
    img.height = <span class="reserved">this</span>.icon_h;
    
    idiv.appendChild( img );
    point.div.appendChild( idiv );
}

<span class="comment">/**
 * This object is a single point on the overlay.
 * The object hold the div and all the stuff to draw and move the point 
 * (symbol, label, icon, etc.).
 *
 * pid			The point ID (string)
 * xml_overlay	The kaXmlOverlay object owner of this point
 */</span>
<span class="reserved">function</span> kaXmlPoint(pid, xml_overlay) {
	<span class="reserved">this</span>.xml_overlay = xml_overlay;
	<span class="reserved">this</span>.pid = pid;
	<span class="reserved">this</span>.divId = <span class="reserved">this</span>.xml_overlay.getDivId(pid);
	<span class="reserved">this</span>.geox = 0;
	<span class="reserved">this</span>.geoy = 0;
	<span class="reserved">this</span>.shown = false;
	
	<span class="reserved">this</span>.graphics = new Array();
	
	<span class="reserved">this</span>.div = document.createElement(<span class="literal">'div'</span>);
	<span class="reserved">this</span>.div.setAttribute(<span class="literal">'id'</span>, <span class="reserved">this</span>.divId);
}

<span class="comment">/**
 * Show the point in the specified geo-position.
 */</span>
kaXmlPoint.<span class="reserved">prototype</span>.placeOnMap = <span class="reserved">function</span>( x, y ) {
	<span class="reserved">if</span> (!<span class="reserved">this</span>.shown) {
		<span class="reserved">this</span>.geox = x;
		<span class="reserved">this</span>.geoy = y;
		<span class="reserved">this</span>.xml_overlay.kaMap.addObjectGeo( <span class="reserved">this</span>.xml_overlay.overlayCanvas, x, y, <span class="reserved">this</span>.div );
		<span class="reserved">this</span>.shown = true;
	} 
}

<span class="comment">/**
 * Delete the point.
 */</span>
kaXmlPoint.<span class="reserved">prototype</span>.removeFromMap = <span class="reserved">function</span>( ) {
	<span class="reserved">if</span> (<span class="reserved">this</span>.shown) {
		<span class="reserved">this</span>.xml_overlay.kaMap.removeObject( <span class="reserved">this</span>.div );
		<span class="reserved">this</span>.shown = false;
	} 
}

<span class="comment">/**
 * Move the point in the specified geo-position.
 */</span>
kaXmlPoint.<span class="reserved">prototype</span>.setPosition = <span class="reserved">function</span>( x, y ) {
	<span class="reserved">if</span> (<span class="reserved">this</span>.shown) {
		<span class="reserved">this</span>.geox = x;
		<span class="reserved">this</span>.geoy = y;
		<span class="reserved">this</span>.div.lat = y;
		<span class="reserved">this</span>.div.lon = x;
	}
}

<span class="comment">/**
 * Add a new kaXmlGraphicElement to this kaXmlPoint.
 * kaXmlGraphicElement subclasses are:
 *  
 *  kaXmlSymbol
 *  kaXmlIcon
 *  kaXmlLabel
 *  kaXmlLinestring
 *  kaXmlPolygon
 *
 * obj	an object of class kaXmlGraphicElement
 */</span>
kaXmlPoint.<span class="reserved">prototype</span>.addGraphic = <span class="reserved">function</span>( obj ) {
		<span class="reserved">this</span>.graphics.push(obj);
		obj.draw(<span class="reserved">this</span>);
}

<span class="comment">/**
 * Clear all the graphic elements of this kaXmlPoint.
 */</span>
kaXmlPoint.<span class="reserved">prototype</span>.clear = <span class="reserved">function</span>() {
	<span class="reserved">this</span>.div.innerHTML = <span class="literal">""</span>;
	<span class="reserved">this</span>.graphics.length = 0;
	<span class="comment">//this.graphics = new Array();</span>
}

<span class="comment">/**
 * Set the HTML content of this kaXmlPoint.
 * This function delete any other content of the point.
 *
 * ihtml		A string containing the HTML
 */</span>
kaXmlPoint.<span class="reserved">prototype</span>.setInnerHtml = <span class="reserved">function</span>(ihtml) {
	<span class="reserved">this</span>.clear();
	<span class="reserved">this</span>.div.innerHTML = ihtml;
}

<span class="comment">/**
 * Parse the XML fragment describing the point. Then draw or translate
 * the point on the map.
 *
 * point_element	 A DOM element &lt;point&gt;
 */</span>
kaXmlPoint.<span class="reserved">prototype</span>.parse = <span class="reserved">function</span>(point_element) {

	var i;
	var x = parseFloat(point_element.getAttribute(<span class="literal">"x"</span>));
	var y = parseFloat(point_element.getAttribute(<span class="literal">"y"</span>));
	var redraw_a = point_element.getAttribute(<span class="literal">"redraw"</span>);
	var redraw = false;
	<span class="reserved">if</span> (redraw_a == <span class="literal">"true"</span>)	redraw = true;
			
	<span class="reserved">if</span> (!<span class="reserved">this</span>.shown) {
		<span class="reserved">this</span>.placeOnMap(x,y);
		<span class="reserved">this</span>.shown = true;
	} <span class="reserved">else</span> {
		<span class="reserved">this</span>.setPosition(x,y);
		
		<span class="comment">// Need redraw?</span>
		<span class="reserved">if</span> (!redraw) <span class="reserved">return</span>;
		
		<span class="comment">// clear and redraw the point</span>
		<span class="reserved">this</span>.clear();
	}
		
	<span class="comment">// look for ihtml element</span>
	var ihtml_element = point_element.getElementsByTagName(<span class="literal">"ihtml"</span>);
	<span class="reserved">for</span> (i=0; i&lt;ihtml_element.length; i++) {
		<span class="reserved">this</span>.div.innerHTML = ihtml_element[i].firstChild.nodeValue;
	}
	
	var t;
	var elements;
	
	<span class="comment">// look for symbol element</span>
	elements = point_element.getElementsByTagName(<span class="literal">"symbol"</span>);
	<span class="reserved">for</span> (i=0; i&lt;elements.length; i++) {
		t = new kaXmlSymbol();
		t.parseElement(<span class="reserved">this</span>, elements[i]);
		<span class="reserved">this</span>.addGraphic(t);
	}
	
	<span class="comment">// look for icon element</span>
	elements = point_element.getElementsByTagName(<span class="literal">"icon"</span>);
	<span class="reserved">for</span> (i=0; i&lt;elements.length; i++) {
		t = new kaXmlIcon();
		t.parseElement(<span class="reserved">this</span>, elements[i]);
		<span class="reserved">this</span>.addGraphic(t);
	}

	<span class="comment">// look for label element</span>
	elements = point_element.getElementsByTagName(<span class="literal">"label"</span>);
	<span class="reserved">for</span> (i=0; i&lt;elements.length; i++) {
		t = new kaXmlLabel();
		t.parseElement(<span class="reserved">this</span>, elements[i]);
		<span class="reserved">this</span>.addGraphic(t);
	}
	
	<span class="comment">// look for linestring element</span>
	elements = point_element.getElementsByTagName(<span class="literal">"linestring"</span>);
	<span class="reserved">for</span> (i=0; i&lt;elements.length; i++) {
		t = new kaXmlLinestring(<span class="reserved">this</span>);
		t.parseElement(<span class="reserved">this</span>, elements[i]);
		<span class="reserved">this</span>.addGraphic(t);
	}
	
	<span class="comment">// look for polygon element</span>
	elements = point_element.getElementsByTagName(<span class="literal">"polygon"</span>);
	<span class="reserved">for</span> (i=0; i&lt;elements.length; i++) {
		t = new kaXmlPolygon(<span class="reserved">this</span>);
		t.parseElement(<span class="reserved">this</span>, elements[i]);
		<span class="reserved">this</span>.addGraphic(t);
	}
}

kaXmlPoint.<span class="reserved">prototype</span>.rescale = <span class="reserved">function</span>(point_element) {
	<span class="reserved">for</span> (i=0; i&lt;<span class="reserved">this</span>.graphics.length; i++) {
		<span class="reserved">this</span>.graphics[i].rescale(<span class="reserved">this</span>);
	}
}

<span class="reserved">function</span> _BrowserIdent() {
	<span class="reserved">this</span>.detect = navigator.userAgent.toLowerCase();
	<span class="reserved">this</span>.OS = null;
	<span class="reserved">this</span>.browser = null;
	<span class="reserved">this</span>.version = null;
	<span class="reserved">this</span>.total = null;
	<span class="reserved">this</span>.thestring = null;
	<span class="reserved">this</span>.place = 0;


	<span class="reserved">if</span> (<span class="reserved">this</span>.checkIt(<span class="literal">'konqueror'</span>)) {
		<span class="reserved">this</span>.browser = <span class="literal">"Konqueror"</span>;
		<span class="reserved">this</span>.OS = <span class="literal">"Linux"</span>;
	} <span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.checkIt(<span class="literal">'safari'</span>)) <span class="reserved">this</span>.browser = <span class="literal">"Safari"</span>;
	<span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.checkIt(<span class="literal">'omniweb'</span>)) <span class="reserved">this</span>.browser = <span class="literal">"OmniWeb"</span>;
	<span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.checkIt(<span class="literal">'opera'</span>)) <span class="reserved">this</span>.browser = <span class="literal">"Opera"</span>
	<span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.checkIt(<span class="literal">'webtv'</span>)) <span class="reserved">this</span>.browser = <span class="literal">"WebTV"</span>;
	<span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.checkIt(<span class="literal">'icab'</span>)) <span class="reserved">this</span>.browser = <span class="literal">"iCab"</span>
	<span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.checkIt(<span class="literal">'msie'</span>)) <span class="reserved">this</span>.browser = <span class="literal">"Internet Explorer"</span>
	<span class="reserved">else</span> <span class="reserved">if</span> (!<span class="reserved">this</span>.checkIt(<span class="literal">'compatible'</span>)) {
		<span class="reserved">this</span>.browser = <span class="literal">"Netscape Navigator"</span>
		<span class="reserved">this</span>.version = <span class="reserved">this</span>.detect.charAt(8);
	} <span class="reserved">else</span> <span class="reserved">this</span>.browser = <span class="literal">"An unknown browser"</span>;

	<span class="reserved">if</span> (!<span class="reserved">this</span>.version) <span class="reserved">this</span>.version = <span class="reserved">this</span>.detect.charAt(<span class="reserved">this</span>.place + <span class="reserved">this</span>.thestring.length);

	<span class="reserved">if</span> (!<span class="reserved">this</span>.OS) {
		<span class="reserved">if</span> (<span class="reserved">this</span>.checkIt(<span class="literal">'linux'</span>)) <span class="reserved">this</span>.OS = <span class="literal">"Linux"</span>;
		<span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.checkIt(<span class="literal">'x11'</span>)) <span class="reserved">this</span>.OS = <span class="literal">"Unix"</span>;
		<span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.checkIt(<span class="literal">'mac'</span>)) <span class="reserved">this</span>.OS = <span class="literal">"Mac"</span>;
		<span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.checkIt(<span class="literal">'win'</span>)) <span class="reserved">this</span>.OS = <span class="literal">"Windows"</span>;
		<span class="reserved">else</span> <span class="reserved">this</span>.OS = <span class="literal">"an unknown operating system"</span>;
	}
}

_BrowserIdent.<span class="reserved">prototype</span>.checkIt = <span class="reserved">function</span> (string) {
	<span class="reserved">this</span>.place = <span class="reserved">this</span>.detect.indexOf(string) + 1;
	<span class="reserved">this</span>.thestring = string;
	<span class="reserved">return</span> <span class="reserved">this</span>.place;
}

_BrowserIdent.<span class="reserved">prototype</span>.setOpacity = <span class="reserved">function</span> (imageobject, opacity) {
	<span class="reserved">if</span> (opacity == undefined || <span class="reserved">this</span>.opacity &gt;= 1) <span class="reserved">return</span> <span class="literal">''</span>;
	<span class="reserved">if</span> (<span class="reserved">this</span>.browser == <span class="literal">"Netscape Navigator"</span>)
		imageobject.style.MozOpacity=opacity;
	<span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.browser == <span class="literal">"Internet Explorer"</span> &amp;&amp; parseInt(<span class="reserved">this</span>.version)&gt;=4) {
		<span class="comment">//filter: alpha(opacity=50);</span>
		var tmp = imageobject.style.cssText;
		tmp = <span class="literal">"filter: alpha(opacity="</span>+(opacity*100)+<span class="literal">");"</span> + tmp;
		imageobject.style.cssText = tmp;
	} <span class="reserved">else</span> {
		var tmp = imageobject.style.cssText;
		tmp = <span class="literal">"opacity: "</span>+opacity+<span class="literal">";"</span> + tmp;	
		imageobject.style.cssText = tmp;
	}
}

_BrowserIdent.<span class="reserved">prototype</span>.getPreferredImageType = <span class="reserved">function</span> () {
	<span class="reserved">if</span> (<span class="reserved">this</span>.browser == <span class="literal">"Netscape Navigator"</span>) <span class="reserved">return</span> <span class="literal">"P"</span>;
	<span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.browser == <span class="literal">"Opera"</span>) <span class="reserved">return</span> <span class="literal">"P"</span>;
	<span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.browser == <span class="literal">"Safari"</span>) <span class="reserved">return</span> <span class="literal">"P"</span>;
	<span class="reserved">else</span> <span class="reserved">return</span> <span class="literal">"G"</span>
}

_BrowserIdent.<span class="reserved">prototype</span>.getPreferredOpacity = <span class="reserved">function</span> () {
	<span class="reserved">if</span> (<span class="reserved">this</span>.browser == <span class="literal">"Netscape Navigator"</span>) <span class="reserved">return</span> <span class="literal">"server"</span>;
	<span class="reserved">else</span> <span class="reserved">if</span> (<span class="reserved">this</span>.browser == <span class="literal">"Opera"</span>) <span class="reserved">return</span> <span class="literal">"server"</span>;
	<span class="reserved">else</span> <span class="reserved">return</span> <span class="literal">"client"</span>
}
</pre>
	<hr>



<!-- ========== START OF NAVBAR ========== -->
<a name="navbar_top"><!-- --></a>
<table border="0" width="100%" cellpadding="1" cellspacing="0">
<tr>
<td colspan=2 bgcolor="#EEEEFF" class="NavBarCell1">
<a name="navbar_top_firstrow"><!-- --></a>
<table border="0" cellpadding="0" cellspacing="3">
  <tr align="center" valign="top">
  
  
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-summary.html"><font class="NavBarFont1"><b>Overview</b></font></a>&nbsp;</td>
  <td bgcolor="#FFFFFF" class="NavBarCell1Rev">	&nbsp;<font class="NavBarFont1Rev"><b>File</b></font>&nbsp;</td>
  

  <td bgcolor="#FFFFFF" class="NavBarCell1"> <font class="NavBarFont1">Class</font>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="overview-tree.html"><font class="NavBarFont1"><b>Tree</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="index-all.html"--><font class="NavBarFont1"><b>Index</b></font></a>&nbsp;</td>
  <td bgcolor="#EEEEFF" class="NavBarCell1">    <a href="help-doc.html"><font class="NavBarFont1"><b>Help</b></font></a>&nbsp;</td>
  </tr>
</table>
</td>
<td bgcolor="#EEEEFF" align="right" valign="top"><em>
<b>ka-Map</b></em>
</td>
</tr>

<tr>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
&nbsp;PREV&nbsp;
&nbsp;NEXT</font></td>
<td bgcolor="white" class="NavBarCell2"><font size="-2">
  <a href="index.html" target="_top"><b>FRAMES</b></a>  &nbsp;
&nbsp;<a href="overview-summary.html" target="_top"><b>NO FRAMES</b></a>
&nbsp;&nbsp;
<script>
  <!--
  if(window==top) {
    document.writeln('<A HREF="allclasses-noframe.html" TARGET=""><B>All Classes</B></A>');
  }
  //-->
</script>
<noscript>
<a href="allclasses-noframe.html" target=""><b>All Classes</b></a>
</noscript>
</font></td>
</tr>
</table>
<!-- =========== END OF NAVBAR =========== -->

<hr>
<font size="-1">

</font>
<div class="jsdoc_ctime">Documentation generated by <a href="http://jsdoc.sourceforge.net/" target="_parent">JSDoc</a> on Wed Mar 15 10:50:59 2006</div>
</body>
</html>
